
// 使用工具生成的模型

import UIKit
import TextAttributes



class DDFocusListModel {

    var recId: Int?
    var recCount: Int?
    var updateCount: Int?
    var recList: [RecList]?

    required init?(json:[String:Any?]?) {
        if json == nil {return nil}
        recId = json?["recId"] as? Int
        recCount = json?["recCount"] as? Int
        updateCount = json?["updateCount"] as? Int
        if let value = json?["recList"]  as? [[String:Any?]]{
            recList = [RecList]()
             value.forEach { (item) in
                 if let i = RecList.init(json:item) {
                     recList?.append(i)
                 }
            }
        }
    }

}

class RecList : ModelCacheHeightProtocol{
    var cacheHeight: CGFloat?
    
    var itemId: Int?
    var textType: Int?
    var createTime: Int?
    var imgs: String?
    var shareTotalNumber: Int?
    var share: Int?
    var imgList: [String]?
    var isFocus: Int?
    var superDaiyan: Int?
    var minProfit: Int?
    var isPraise: Int?
    var textSourceType: Int?
    var userId: Int?
    var praise: Int?
    var commentCount: Int?
    var isRelateItem: Int?
    var recType: Int?
    var gifUrl: String?
    var consumerId: Int?
    var shopId: Int?
    var recommendationType: Int?
    var itemBos: [Int]?
    var imgDimensionList: [ImgDimensionList]?
    var userType: Int?
    var nickName: String?
    var recDesc: String?
    var headImg: String?
    var recId: Int?
    var needShowFocus: Int?
    var videoUrl:String?
    var videoCoverImg:String?

    required init?(json:[String:Any?]?) {
        if json == nil {return nil}
        videoUrl = json?["videoUrl"] as? String
        videoCoverImg = json?["videoCoverImg"] as? String
        itemId = json?["itemId"] as? Int
        textType = json?["textType"] as? Int
        createTime = json?["createTime"] as? Int
        imgs = json?["imgs"] as? String
        shareTotalNumber = json?["shareTotalNumber"] as? Int
        share = json?["share"] as? Int
        isFocus = json?["isFocus"] as? Int
        superDaiyan = json?["superDaiyan"] as? Int
        minProfit = json?["minProfit"] as? Int
        isPraise = json?["isPraise"] as? Int
        textSourceType = json?["textSourceType"] as? Int
        userId = json?["userId"] as? Int
        praise = json?["praise"] as? Int
        commentCount = json?["commentCount"] as? Int
        isRelateItem = json?["isRelateItem"] as? Int
        recType = json?["recType"] as? Int
        gifUrl = json?["gifUrl"] as? String
        consumerId = json?["consumerId"] as? Int
        shopId = json?["shopId"] as? Int
        recommendationType = json?["recommendationType"] as? Int
        userType = json?["userType"] as? Int
        nickName = json?["nickName"] as? String
        recDesc = json?["recDesc"] as? String
        headImg = json?["headImg"] as? String
        recId = json?["recId"] as? Int
        needShowFocus = json?["needShowFocus"] as? Int
        imgList = json?["imgList"] as? [String]
        itemBos = json?["itemBos"] as? [Int]
        if let value = json?["imgDimensionList"]  as? [[String:Any?]]{
            imgDimensionList = [ImgDimensionList]()
             value.forEach { (item) in
                 if let i = ImgDimensionList.init(json:item) {
                     imgDimensionList?.append(i)
                 }
            }
        }
    }
    var cellIndex: Int = 0
    // 展示全文
    var showMore = false;
    // 是否字符超过规定行数
    var moreThanRuleLines:Bool?
    private var _contentAttribute:NSMutableAttributedString?
    var contentAttribute:NSAttributedString? {
        get {
            if let _ = _contentAttribute {
                return  _contentAttribute!
            }
            let attrs = TextAttributes()
                .font(UIFont.systemFont(ofSize: 14))
                .foregroundColor(Color.init(hex: 0x333333))
                .lineSpacing(12)
                .lineBreakMode(.byTruncatingTail)
            _contentAttribute = NSMutableAttributedString.init(string: recDesc ?? "",attributes: attrs)
            return _contentAttribute
        
        }
    }
    
    var isTheOne = false; //bei xuanzhong de nage ren,jiang zuowei shipin bofangqi de zhu 

}

class ImgDimensionList {

    var height: Int?
    var width: Int?

    required init?(json:[String:Any?]?) {
        if json == nil {return nil}
        height = json?["height"] as? Int
        width = json?["width"] as? Int
    }

}
